#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    long long m, n;
    cin >> m >> n;

    vector<long long> result;

    for (long long i = n; i <= m; ++i) {
        if (i % n == 0 || to_string(i).find(to_string(n)) != string::npos) {
            result.push_back(i);
        }
    }

    // 输出结果
    for (size_t i = 0; i < result.size(); ++i) {
        if (i > 0) cout << " ";
        cout << result[i];
    }
    cout << endl;

    return 0;
}